from django.db import models


class UserInfo(models.Model):
    """用户基本表"""
    id = models.AutoField(verbose_name='ID', primary_key=True)         # 主键
    username = models.CharField(verbose_name='用户名',max_length=32,unique=True)         # 用户名
    password = models.CharField(verbose_name='用户密码', max_length=32)          # 密码
    email = models.EmailField(verbose_name='Email')                 # 邮箱
    is_vip = models.BooleanField(verbose_name='Vip', default=False)     # 是否为会员
    is_delete = models.BooleanField(verbose_name='是否删除', default=False)      # 是否删除
    create_time = models.DateTimeField(verbose_name= '创建时间',auto_now_add=True)       # 创建时间
    update_time = models.DateTimeField(verbose_name= '更新时间',auto_now=True)           # 更新时间
    points_balance = models.IntegerField(verbose_name='积分余额', default=1000)         # 积分余额

class UserDetail(models.Model):
    """用户详细信息"""
    id = models.AutoField(verbose_name='ID', primary_key=True)
    """级联删除"""
    userId = models.OneToOneField( on_delete=models.CASCADE,to="UserInfo",to_field="id")
    choice = (
        ('male', '男'),
        ('female', '女'),
    )
    sex = models.CharField(verbose_name='性别', max_length=32, choices=choice, default='男')
    birsthday = models.DateField(verbose_name='生日', auto_now_add=True)
    address = models.CharField(verbose_name='地址', max_length=32, default='北京')
    job = models.CharField(verbose_name='工作', max_length=32, default='程序员')
    company = models.CharField(verbose_name='公司', max_length=32, default='腾讯')
    education = models.CharField(verbose_name='学历', max_length=32, default='本科')
    introduce = models.CharField(verbose_name='个人介绍', max_length=32, default='')
    # head_img = models.ImageField(verbose_name='头像', upload_to='head_img/', default='head_img/default.jpg')
    nickname = models.CharField(verbose_name='昵称', max_length=32, default='新用户')
    create_time = models.DateTimeField(verbose_name= '创建时间',auto_now_add=True)
    update_time = models.DateTimeField(verbose_name= '更新时间',auto_now=True)


